<template>
	<view class="page">
		<view class="list" v-if="comit">
			<view class="item">
				<text class="key">审批人选择</text>
				<uni-icons type="compose" size="20"></uni-icons>
				<picker :value="approvalIndex" :range="approvalArrayName" @change="approvalChange">{{approvalArrayName[approvalIndex]==undefined?"请选择":approvalArrayName[approvalIndex]}}
				</picker>
			</view>
			<view class="item">
				<text class="key">姓名</text>
				<text class="value">{{name}}</text>
			</view>
			<view class="item">
				<text class="key">联系号码</text>
				<text class="value">{{account}}</text>
			</view>
			<view class="item">
				<text class="key">邮箱</text>
				<text class="value">{{email}}</text>
			</view>
			<view class="item">
				<text class="key">当前所在组织</text>
				<text class="value">{{organization}}</text>
			</view>
			<view class="item">
				<text class="key">当前任职岗位</text>
				<text class="value">{{post}}</text>
			</view>
			<view class="item">
				<text class="key">开始日期</text>
				<uni-icons type="compose" size="20"></uni-icons>
				<picker mode="date" :value="selectStartDate" :start="startDate" :end="endDate" @change="bindStartDateChange">
					<view class="uni-input">{{selectStartDate}}</view>
				</picker>
			</view>
			<view class="item">
				<text class="key">开始时间</text>
				<uni-icons type="compose" size="20"></uni-icons>
				<picker mode="time" :value="selectStartTime" :start="curStartTime"  @change="bindStartTimeChange">
					<view class="uni-input">{{selectStartTime}}</view>
				</picker>
			</view>
			<view class="item">
				<text class="key">结束日期</text>
				<uni-icons type="compose" size="20"></uni-icons>
				<picker mode="date" :value="selectEndDate" :start="startDate" :end="endDate" @change="bindEndDateChange">
					<view class="uni-input">{{selectEndDate}}</view>
				</picker>
			</view>
			<view class="item">
				<text class="key">结束时间</text>
				<uni-icons type="compose" size="20"></uni-icons>
				<picker mode="time" :value="selectEndTime" :start="curEndTime"  @change="bindEndTimeChange">
					<view class="uni-input">{{selectEndTime}}</view>
				</picker>
			</view>
			<view class="item">
				<text class="key">请假类型选择</text>
				<uni-icons type="compose" size="20"></uni-icons>
				<picker :value="leaveIndex" :range="leaveArrayName" @change="leaveChange">{{leaveArrayName[leaveIndex]==undefined?"请选择":leaveArrayName[leaveIndex]}}
				</picker>
			</view>
			<view class="item" @tap="editReason">
				<text class="key">请假说明</text>
				<uni-icons type="compose" size="20"></uni-icons>
				<text class="value">{{reason}}</text>
			</view>
			<uni-popup ref="popupReason" type="dialog">
				<uni-popup-dialog mode="input" title="请假理由" :value="reason" placeholder="请简单说明一下请假理由,不超过30字!" @confirm="finishReason">
				</uni-popup-dialog>
			</uni-popup>
			<view class="item">
				<text class="key">申请日期</text>
				<text class="value">{{createTime}}</text>
			</view>
		</view>
		<uni-section title="请选择请假证明的照片(限1张)" type="line" v-if="comit">
			<view class="example-body" >
				<uni-file-picker
					file-mediatype="image"
					disable-preview
					:del-icon="false"
					mode="grid"
					ref="file"
					file-extname="png,jpg"
					:limit="1"
					:auto-upload="false"
					:source-type=source
					@select="getPhotoPath"
				></uni-file-picker>
			</view>
		</uni-section>
		<uni-title type="h1" align="center" title="请假凭证" v-if="over"></uni-title>
		<view class="list" v-if="over">
			<view class="item">
				<text class="key">姓名</text>
				<text class="value">{{curName}}</text>
			</view>
			<view class="item">
				<text class="key">联系号码</text>
				<text class="value">{{curAccount}}</text>
			</view>
			<view class="item">
				<text class="key">邮箱</text>
				<text class="value">{{curMail}}</text>
			</view>
			<view class="item">
				<text class="key">所在组织</text>
				<text class="value">{{curOrganization}}</text>
			</view>
			<view class="item">
				<text class="key">任职岗位</text>
				<text class="value">{{curPost}}</text>
			</view>
			<view class="item">
				<text class="key">请假类型</text>
				<text class="value">{{curLeaveType}}</text>
			</view>
			<view class="item">
				<text class="key">请假说明</text>
				<text class="value">{{curLeaveReason}}</text>
			</view>
			<view class="item">
				<text class="key">请假开始时间</text>
				<text class="value">{{curLeaveStartTime}}</text>
			</view>
			<view class="item">
				<text class="key">请假结束时间</text>
				<text class="value">{{curLeaveEndTime}}</text>
			</view>
		</view>
		<uni-steps :options="stepList" :active-icon="icon" :active-color="color" :active="active" direction="column" v-if="step" />
		<button class="save-btn" @tap="save" v-if="comit">提 交</button>
		<button class="save-btn" @tap="undo" v-if="revoke">撤 销</button>
		<button class="save-btn" @tap="remit" v-if="over" :disabled="isOver">销 假</button>
	</view>
</template>

<script>
import uniPopup from '@/components/uni-popup/uni-popup.vue';
import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue';
import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue';
import uniFilePicker from '@/components/uni-file-picker/uni-file-picker.vue';
import uniSection from '@/components/uni-section/uni-section.vue';
import uniSteps from '@/components/uni-steps/uni-steps.vue';
export default {
	components: {
		uniPopup,
		uniPopupMessage,
		uniPopupDialog,
		uniFilePicker,
		uniSection,
		uniSteps
	},
    data() {
        const currentDate = this.getDate({
            format: true
        })
        return {
			//当前审批
			approvalId:0,
			//当前请假id
			leaveDocId:0,
			//审批人选择
			approvalArrayName:[],
			approvalArrayId:[],
			approvalUserId:-1,
			approvalIndex:0,
			//姓名
			name:'',
			//联系号码
			account:'',
			//邮箱
			email:'',
			// 所在组织
			organization:'',
			organizationId:0,
			// 所在岗位
			post:'',
			//当前所在组织id
			postId:0,
			//当前秒数
			seconds:'',
			//当前时间点
			curTime:'',
			//当前开始时间点
			curStartTime:'',
			//选择的开始日期 yyyy-MM-dd
            selectStartDate: currentDate,
			//选择的开始时间
            selectStartTime: '',
			//选择开始日期
			getStartDate:'',
			//选择开始时间
			getStartTime:'',
			//请假开始时间
			startTime:'',
			//当前结束时间点
			curEndTime:'',
			//选择的结束日期 yyyy-MM-dd
			selectEndDate: currentDate,
			//选择的结束时间
			selectEndTime:'',
			//选择结束日期
			getEndDate:'',
			//选择结束时间
			getEndTime:'',
			//请假结束时间
			endTime:'',
			//请假类型选择
			leaveArrayName:[],
			leaveArrayId:[],
			leaveId:-1,
			leaveIndex:0,
			//请假理由
			reason:'',
			// 当前日期
			nowDate:'',
			// 当前时间
			nowTime:'',
			// 登记日期
			createTime:'',
			//证明照片路径
			tempFilePaths:[],
			//证明文件的路径
			certificate:'',
			// 从本地相册中选择
			source:['album'],
			// 提交状态
			comit:true,
			// 审核状态
			// 撤销状态
			revoke:false,
			//当前审批id
			approvalId:0,
			// 审核步骤
			step:false,
			// 激活步骤
			active: 0,
			// 步骤线
			stepList: [],
			// 步骤线颜色
			color:"#007AFF",
			// 步骤前icon
			icon:"smallcircle-filled",
			// 完成状态
			over:false,
			//请假属性
			//姓名
			curName:'',
			//联系号码
			curAccount:'',
			//邮箱
			curMail:'',
			//所在组织
			curOrganization:'',
			//任职岗位
			curPost:'',
			//请假类型
			curLeaveType:'',
			//请假说明
			curLeaveReason:'',
			//请假开始时间
			curLeaveStartTime:'',
			//请假结束时间
			curLeaveEndTime:'',
			//是否可销假
			isOver:true
        }
    },
	onLoad:function(){
		let that = this;
		let now = new Date();
		let year = now.getFullYear();
		let month = now.getMonth() + 1;
		month = month < 10 ? '0' + month : month;
		let date = now.getDate();
		date = date < 10 ? '0' + date : date;
		let yyyymmdd = year + '/' + month + '/' + date
		let yyyy_mm_dd = year + '-' + month + '-' + date
		that.nowDate = yyyymmdd;
		that.nowTime = yyyy_mm_dd;
		//加载请假类型
		this.loadLeaveData(this);
		// 加载登记时间
		this.loadCreateTime(this);
	},
	onShow:function(){
		//加载获取当前时间点
		this.loadCurTime();
		//初始化用户信息
		this.loadInitUser(this);
		// 判断当前页面是否为审批状态
		this.curApproval(this);
	},
    computed: {
		//日期可选范围的开始日期
        startDate() {
            return this.getDate('start');
        },
		//日期可选范围的结束日期
        endDate() {
            return this.getDate('end');
        }
    },
    methods: {
		//判断当前页面是否为审批状态
		curApproval:function(ref){
			ref.ajax(ref.url.curApproval,'POST',{
				approvalType:'leave'
			},function(resp){
				let data = resp.data;
				//如果是
				if(data.curApproval.length>0){
					//当前审批的数据
					let cur = data.curApproval[0];
					//提交内容不可见，提交按钮不可见
					ref.comit = false;
					//步骤条可见
					ref.step = true;
					ref.active = cur.approvalStatus;
					//当前审核id
					ref.approvalId = cur.id;
					//待审核时显示
					if(cur.approvalStatus==1){
						ref.stepList = [
							{title: '已提交',desc: '提交日期:'+ref.formatDataTime(cur.applyTime)}, 
							{title: '待审核',desc: '审核中，请耐心等待……'},
							]
							ref.revoke = true
					}
					//已审核（通过时显示）
					if(cur.approvalStatus==2){
						ref.color="#55aa00"
						ref.revoke = false
						ref.over = true
						ref.stepList = [
							{title: '已提交',desc: '提交日期:'+ref.formatDataTime(cur.applyTime)}, 
							{title: '待审核',desc: '审核日期:'+ref.formatDataTime(cur.applyTime)},
							{title: '通过',desc: '本次提交已通过'}
							]
						//获取当前启用的请假id
						ref.getCurId();
						if(uni.getStorageSync("leave-id")===''){
							uni.switchTab({
								url:'/pages/index/index'
							})
						}
						let curLeaveStartTime='';
						let curLeaveEndTime = '';
						ref.ajax(ref.url.getLeave,'POST',{
							id:uni.getStorageSync("leave-id")
						},function(resp){
							let data = resp.data;
							if(data.code == 20000){
								let d = data.data;
								//请假开始时间
								curLeaveStartTime = d.startTime;
								//请假结束时间
								curLeaveEndTime = d.endTime;
							}
						});
						if(ref.createTime >= curLeaveStartTime && ref.createTime <= curLeaveEndTime){
							ref.isOver = true;
							uni.showToast({
								icon: 'error',
								title: '当前无法销假',
							});
						}else{
							ref.isOver = false;
						}
						//根据当前请假id查询请假具体信息
						ref.ajax(ref.url.getLeave,'POST',{
							id:uni.getStorageSync("leave-id")
						},function(resp){
							let data = resp.data;
							if(data.code == 20000){
								let d = data.data;
								ref.curName = d.user.name;
								//联系号码
								ref.curAccount = d.user.account;
								//邮箱
								ref.curMail = d.user.email;
								//所在组织
								ref.curOrganization = d.user.organization.name;
								//任职岗位
								ref.curPost = d.user.job.name;
								//请假类型
								ref.curLeaveType = d.type.name;
								//请假说明
								ref.curLeaveReason = d.reason;
								//请假开始时间
								ref.curLeaveStartTime = d.startTime;
								//请假结束时间
								ref.curLeaveEndTime = d.endTime;
							}
						});
					}
					//已审核（未通过时显示）
					if(cur.approvalStatus==3){
						ref.revoke = false
						ref.over = true
						ref.stepList = [
							{title: '已提交',desc: '提交日期:'+ref.formatDataTime(cur.applyTime)}, 
							{title: '待审核',desc: '审核日期:'+ref.formatDataTime(cur.applyTime)},
							{title: '未通过',desc: '未通过理由:'+cur.approvalReason}
							]
						ref.color="#ff0000"
						ref.getCurId();
						if(uni.getStorageSync("leave-id")===''){
							uni.switchTab({
								url:'/pages/index/index'
							})
						}
						ref.isOver = false;
						let message = '未通过'
						//根据当前请假id查询请假具体信息
						ref.ajax(ref.url.getLeave,'POST',{
							id:uni.getStorageSync("leave-id")
						},function(resp){
							let data = resp.data;
							if(data.code == 20000){
								let d = data.data;
								ref.curName = message;
								//联系号码
								ref.curAccount = message;
								//邮箱
								ref.curMail = message;
								//所在组织
								ref.curOrganization = message;
								//任职岗位
								ref.curPost = message;
								//请假类型
								ref.curLeaveType = message;
								//请假说明
								ref.curLeaveReason = message;
								//请假开始时间
								ref.curLeaveStartTime = message;
								//请假结束时间
								ref.curLeaveEndTime = message;
							}
						});
					}
				}
			});
		},
		//加载审批人数据
		loadArrovalData(ref){
			ref.ajax(ref.url.getAdmins,'POST',{
				id:ref.organizationId
			},function(resp){
				if(ref.approvalArrayId.length<=0){
					let data = resp.data.data;
					let arrName = [];
					let arrId=[];
					for(let one of data){
						ref.approvalArrayId.push(one.id);
						ref.approvalArrayName.push(one.name);
					}
					ref.approvalUserId = ref.approvalArrayId[0];
					ref.approvalIndex = ref.approvalArrayId.indexOf(ref.approvalUserId);
					uni.setStorageSync("leave-approvalUserId",ref.approvalUserId);
				}
			});
		},
		//选择审批人
		approvalChange: function(e) {
			let that = this;
			that.approvalIndex = e.detail.value;
			uni.setStorageSync("leave-approvalUserId",that.approvalArrayId[that.approvalIndex])
			that.approvalUserId = uni.getStorageSync("leave-approvalUserId");
		},
		//加载初始化用户信息
		loadInitUser:function(ref){
				ref.ajax(ref.url.getuserinfo, "POST", null, function(resp) {
				let data = resp.data;
				let user = data.userinfo.user;
				let roles = data.userinfo.roles;
				if(!user.isRegistration){
					uni.showToast({
						title:"未登记",
						icon:'error'
					});
					setTimeout(function(){
						uni.switchTab({
							url:'../index/index'
						})
					},1000)
				}
				let message = "未填写";
				// 姓名
				if(user.name==null){
					ref.name = "新员工"
				}else{
					ref.name = user.name;
				}
				// 当前所在组织
				if(user.organization==null){
					ref.organization = message
				}else{
					ref.organization = user.organization.name
					ref.organizationId = user.organization.id;
					//加载审批人数据
					ref.loadArrovalData(ref);
				}
				//当前所在岗位
				if(user.job==null){
					ref.post = message
				}else{
					ref.post = user.job.name
					ref.postId = user.job.id
				}
				// 账号
				if(user.account==null){
					ref.account = message
				}else{
					ref.account = user.account
				}
				// 电子邮件
				if(user.email==null){
					ref.email = message
				}else{
					ref.email = user.email
				}
			});
			if(uni.getStorageSync('leave-reason').length>0){
				ref.reason = uni.getStorageSync('leave-reason');
			}
		},
		//选择开始日期
        bindStartDateChange: function(e) {
            this.getStartDate = e.detail.value;
			this.selectStartDate = this.getStartDate;
			if(this.getStartDate > this.nowTime){
				this.curStartTime = '00:00'
			}
        },
		//选择开始时间
        bindStartTimeChange: function(e) {
			if(this.getStartDate.length<=0){
				uni.showToast({
					title:"请选择开始日期",
					icon:'none'
				});
			}else{
				this.getStartTime = e.detail.value;
				this.selectStartTime = this.getStartTime;
				this.startTime = this.getStartDate+" "+this.getStartTime+":"+this.seconds;
			}
        },
		//选择结束日期
		bindEndDateChange:function(e){
			if(this.getStartTime.length<=0){
				uni.showToast({
					title:"请选择开始时间",
					icon:'none'
				});
			}
			if(this.getStartDate>e.detail.value){
				uni.showToast({
					title:"请正确选择",
					icon:'error'
				});
			}
			this.getEndDate = e.detail.value;
			this.selectEndDate = this.getEndDate;
			console.log(this.getEndDate)
			if(this.getEndDate > this.nowTime){
				this.curEndTime = '00:00'
			}
		},
		//选择结束时间
		bindEndTimeChange:function(e){
			if(this.getEndDate.length<=0){
				uni.showToast({
					title:"请选择结束日期",
					icon:'none'
				});
			}
			if(this.getStartDate == this.getEndDate){
				if(this.getStartTime>=e.detail.value){
					uni.showToast({
						title:"请正确选择",
						icon:'error'
					});
				}
			}
			this.getEndTime = e.detail.value;
			this.selectEndTime = this.getEndTime;
			this.endTime = this.getEndDate+" "+this.getEndTime+":"+this.seconds;
		},
		//加载当前时间
		loadCurTime(){
			let now = new Date();
			// 获取小时、分钟，并进行格式化
			let hours = now.getHours();
			hours = hours < 10 ? '0' + hours : hours; // 对于24小时制不需要额外处理
			let minutes = now.getMinutes();
			minutes = minutes < 10 ? '0' + minutes : minutes;
			let seconds = now.getSeconds();
			this.seconds = seconds < 10 ? '0' + seconds : seconds;
			this.curTime = hours+":"+minutes;
			this.curStartTime = this.curTime;
			this.curEndTime = (hours===23?23:hours+1)+":"+minutes;
			this.selectStartTime = hours+":"+minutes;
			this.selectEndTime = (hours===23?23:hours+1)+":"+minutes;
		},
		//获取可选择日期的范围
        getDate(type) {
            const date = new Date();
            let year = date.getFullYear();
            let month = date.getMonth() + 1;
            let day = date.getDate();
            if (type === 'start') {
                year = year + 0;
            } else if (type === 'end') {
                year = year + 2;
            }
            month = month > 9 ? month : '0' + month;
            day = day > 9 ? day : '0' + day;
            return `${year}-${month}-${day}`;
        },
		//加载请假类型
		loadLeaveData(ref){
			let that = this;
			that.ajax(that.url.getDict,'POST',{
				type:"leave"
			},function(resp){
				let data = resp.data.data;
				let arrName = [];
				let arrId=[];
				for(let one of data){
					ref.leaveArrayId.push(one.id);
					ref.leaveArrayName.push(one.name);
				}
				ref.leaveId = ref.leaveArrayId[0];
				ref.leaveIndex = ref.leaveArrayId.indexOf(ref.leaveId)
			})
		},
		//选择请假类型
		leaveChange:function(e){
			let that = this;
			that.leaveIndex = e.detail.value;
			uni.setStorageSync("leave-leaveId",that.leaveArrayId[that.leaveIndex])
			that.leaveId = uni.getStorageSync("leave-leaveId");
		},
		//编辑申请理由
		editReason:function(){
			this.$refs.popupReason.open();
		},
		//完成申请理由编辑
		finishReason:function(done,value){
			let that = this;
			if(value.length>=30){
				uni.showToast({
					title:"字数太多",
					icon:'error'
				});
				return;
			}else{
				uni.setStorageSync("leave-reason",value)
				that.reason = uni.getStorageSync("leave-reason");
			}
			done();
		},
		// 加载登记时间
		loadCreateTime(ref){
			let now = new Date();
			// 获取小时、分钟和秒数，并进行格式化
			let hours = now.getHours();
			hours = hours < 10 ? '0' + hours : hours; // 对于24小时制不需要额外处理
			let minutes = now.getMinutes();
			minutes = minutes < 10 ? '0' + minutes : minutes;
			let seconds = now.getSeconds();
			seconds = seconds < 10 ? '0' + seconds : seconds;
			ref.createTime = ref.nowTime+' '+hours+':'+minutes+':'+ seconds;
		},
		// 获取照片路径
		getPhotoPath(e){
			let that = this;
			that.tempFilePaths = e.tempFilePaths;
		},
		//提交申请
		save(){
			let that = this;
			if(
				//选择的审批人的id是否选择
				that.approvalUserId<=0 ||
				//请假说明是否填写
				that.reason.length<=0 ||
				//开始时间是否选择
				that.startTime.length<=0 ||
				//结束时间是否选择
				that.endTime.length<=0 ||
				//相关材料是否存在
				that.tempFilePaths.length<=0 ||
				//请假类型id是否存在
				that.leaveId<=0
			){
				console.log(that.approvalUserId);
				console.log(that.reason);
				console.log(that.startTime);
				console.log(that.endTime);
				console.log(that.tempFilePaths);
				console.log(that.leaveId);
				uni.showToast({
					icon: 'error',
					title: '请填写完整相关内容',
				});
			}else{
				uni.showModal({
					title: '提示',
					content: '是否提交请假申请信息',
					success: function(e) {
						if(e.confirm){
							let curApprovalUserId='';
							if(typeof(uni.getStorageSync('leave-approvalUserId'))!='number'){
								curApprovalUserId = that.approvalUserId
							}else{
								curApprovalUserId = uni.getStorageSync('leave-approvalUserId')
							}
							//上传图片证明并获取url路径
							uni.uploadFile({
								url:that.url.uploadCosFile,
								filePath:that.tempFilePaths[0],
								name:"files",
								header:{
									token:uni.getStorageSync("token")
								},
								formData:{
									type:'leave'
								},
								success:(uploadFileRes) => {
									let data = JSON.parse(uploadFileRes.data);
									if(data.result.urls.length>0){
										that.certificate = data.result.urls[0];
										uni.setStorageSync("leave-certificate",data.result.urls[0]);
									}
								}
							});
							//提交一条相关数据到请假记录
							that.ajax(that.url.setLeave,'POST',{
								typeId:that.leaveId,
								reason: that.reason,
								startTime:that.startTime,
								endTime:that.endTime,
								resources: uni.getStorageSync("leave-certificate")
							},function(resp){
								let data = resp.data
								if(data.code===20000){
									//提交一条审批信息到后端审批者界面审批
									that.ajax(that.url.applyApproval,'POST',{
										approvalId:curApprovalUserId,
										applyReason:that.reason,
										certificate:uni.getStorageSync("leave-certificate"),
										approvalType:"leave"
									},function(resp){
										let data = resp.data;
										if(data.code === 20000){
											let data = resp.data;
											//激发为待审核状态（第一次提交时或重新提交时）
											if(data.code===20000){
												//提交内容不可见，提交按钮不可见
												that.comit = false
												//撤销按钮可用
												that.revoke = true
												//步骤条可用
												that.step = true
												//获取当前的审批id
												that.approvalId = data.approvalInfo.id;
												//待审核状态
												that.active = data.approvalInfo.approvalStatus;
												that.stepList = [
													{title: '已提交',desc: '提交日期:'+that.formatDataTime(data.approvalInfo.applyTime)}, 
													{title: '待审核',desc: '审核中，请耐心等待……'},
													]
											}
										}
									});
								}
							});
						}
					}
				});
			}
		},
		//撤销审批
		undo:function(){
			let that = this;
			that.ajax(that.url.curApproval,'POST',{
				approvalType:'leave'
			},function(resp){
				let data = resp.data;
				//如果是
				if(data.curApproval.length>0){
					//当前审批的数据
					let cur = data.curApproval[0];
					if(cur.approvalStatus==2 || cur.approvalStatus==3){
						uni.showToast({
							icon: 'none',
							title: '无法撤销，已经审核，请重新查看',
						});
						uni.switchTab({
							url:'/pages/index/index'
						})
					}
				}
			});
			uni.showModal({
				title: '提示',
				content: '是否确认撤销请假信息',
				success: function(e) {
					if (e.confirm) {
						let form={
							id:that.approvalId,
							cutStatus:1
						}
						that.getCurId();
						that.ajax(that.url.setLeaveIsEnable,'PUT',{
							id:uni.getStorageSync("leave-id")+1,
							isEnable:false
						},function(resp){
							let data = resp.data;
							if(data.code==20000){
								that.ajax(that.url.setCut,'POST',form,function(resp){
									let data = resp.data;
									if(data.code===20000){
										uni.showToast({
											icon: 'success',
											title: data.msg,
										});
										//撤销按钮不可见
										that.revoke = false;
										//步骤条不可见
										that.step = false;
										//提交内容和提交按钮可见
										that.comit = true;
										//恢复步骤条颜色
										that.color = "#007AFF";
									}
								})
							}
						});
						
					}
				}
			});
		},
		//重新提交
		remit:function(){
			let that = this;
			uni.showModal({
				title: '提示',
				content: '是否确认销假',
				success: function(e) {
					if (e.confirm) {
						let form={
							id:that.approvalId,
							cutStatus:1
						}
						that.ajax(that.url.setLeaveIsEnable,'PUT',{
							id:uni.getStorageSync("leave-id"),
							isEnable:false
						},function(resp){
							let data = resp.data;
							if(data.code==20000){
								that.ajax(that.url.setCut,'POST',form,function(resp){
									let data = resp.data;
									if(data.code===20000){
										uni.showToast({
											icon: 'success',
											title: '再次提交',
										});
										//重新提交按钮不可见
										that.over = false;
										//步骤条不可见
										that.step = false;
										//提交内容和提交按钮可见
										that.comit = true;
										//恢复颜色
										that.color = "#007AFF";
									}
								});
							}
						});
					}
				}
			});
		},
		//获取当前请假id
		getCurId(){
			let that = this;
			that.ajax(that.url.getLeaveByIsEnable,'POST',{
				isEnable:true
			},function(resp){
				let data = resp.data;
				if(data.code == 20000){
					that.leaveDocId = data.data.id;
					uni.setStorageSync("leave-id",data.data.id)
				}
			})
		},
    }
}
</script>


<style lang="less">
@import url('leave.less');
</style>
